//
//  HouseDetailNavView.m
//  YJRenter
//
//  Created by 文彬 on 2018/7/2.
//  Copyright © 2018年 文彬. All rights reserved.
//

#import "HouseDetailNavView.h"

@implementation HouseDetailNavView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (id)initWithFrame:(CGRect)frame{
    
    self =[super initWithFrame:frame];
    if (self) {
        
        [self initControl];
        
    }
    return self;
}

- (void)initControl{
    
   
    UIButton *imgBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    imgBtn.frame = CGRectMake(0, 10, 18, 25);
    [imgBtn setImage:[UIImage imageNamed:@"back_bt"] forState:UIControlStateNormal];
    [self addSubview:imgBtn];
    [imgBtn makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.height.equalTo(@35);
        make.width.equalTo(@40);
        make.centerY.equalTo(self.centerY);
    }];
    WeakObj(self)
    [imgBtn buttonClick:^{
        if ([selfWeak.delegate respondsToSelector:@selector(houseDetailNavClick:)]) {
            [selfWeak.delegate houseDetailNavClick:10];
        }
    }];
    
    for (int i=0; i<3; i++) {
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setBackgroundImage:[UIImage imageNamed:@"ic_message"] forState:UIControlStateNormal];
        [self addSubview:button];
        [button makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(@(-(10+30*i+20*i)));
            make.width.height.equalTo(@30);
            make.centerY.equalTo(self.centerY);
        }];
    }
}

- (void)scrollOffset:(float)offset{
    
    if (offset<200) {
        self.backgroundColor = RGBACOLOR(255, 255, 255,offset/200.0 );
    }
    else if(offset>=200){
        
        self.backgroundColor = [UIColor whiteColor];
    }
}

@end
